package com.ljkj.blockpay.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import com.kongzue.baseokhttp.util.JsonList;
import com.kongzue.baseokhttp.util.JsonMap;
import com.ljkj.blockpay.R;
import com.ljkj.blockpay.basedata.BaseActivity;
import com.ljkj.blockpay.databinding.ActivityMmaddressBinding;
import com.ljkj.blockpay.presenter.AddressInter;
import com.ljkj.blockpay.presenter.MMAddressPresenter;
import com.ljkj.blockpay.ui.adapter.AddressAdapter;
import com.ljkj.blockpay.util.ToggleToActivity;
import com.ljkj.blockpay.widget.ClickListener;
import com.luck.picture.lib.tools.ToastUtils;

/**
 * 提币地址页面
 */
public class MMAddressActivity extends BaseActivity<ActivityMmaddressBinding, MMAddressPresenter> implements AddressInter.AddressInterView, ClickListener {

    private AddressAdapter addressAdapter;

    @Override
    public int initContentView() {
        return R.layout.activity_mmaddress;
    }

    @Override
    protected MMAddressPresenter createPresenter() {
        return new MMAddressPresenter(this,this);
    }

    @Override
    protected void init(Bundle savedInstanceState) {


    }

    @Override
    protected void initData() {
        super.initData();
        binding.setOnClick(this);
        binding.tvTitle.setTitleContent(R.string.mentionmoneyaddress);
        binding.tvTitle.setLeftBackFinish(this);
        getPresenter().searchaddress();

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(RecyclerView.VERTICAL);
        addressAdapter = new AddressAdapter(R.layout.addresslist_layout);
        binding.rvAddresslist.setLayoutManager(layoutManager);
        binding.rvAddresslist.setAdapter(addressAdapter);

    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_address:
                ToggleToActivity.toWithdrawDetailActivity(this);
                break;
        }
    }

    @Override
    public void deleteSuccess(JsonMap jsonMap) {

    }

    @Override
    public void searchSuccess(JsonList jsonList) {
        if (jsonList.size() <= 0){
           binding.llLayout.setVisibility(View.VISIBLE);
        } else {
            addressAdapter.setNewData(jsonList);
        }

    }
}